<include file="Public:header" />
<include file="Public:menu" menu_report="curr" />
<include file="Public:navibar" />
<div id="main">
    <h4>举报处理</h4>
    <hr class="dash" />
    <div class="console">
        <a href="__URL__/index" class="<eq name='Think.get.filter' value=''>curr</eq>">未处理的</a>&nbsp;|&nbsp;
        <a href="__URL__/index/filter/processed" class="<eq name='Think.get.filter' value='processed'>curr</eq>">已处理的</a>
    </div>

    <form action="__URL__/dispose" method="post">
        <table class="list" width="100%">
            <thead>
                <tr>
                    <th width="3%"><input type="checkbox" class="check_all" name="id[]" /></th>
                    <th width="5%">ID</th>
                    <th width="20%">举报人</th>
                    <th width="4%">类型</th>
                    <th width="13%">举报对象</th>
                    <th>原因</th>
                    <th width="14%">举报时间</th>
                    <th width="5%">状态</th>
                    <eq name="Think.get.filter" value="">
                    <th width="10%">操作</th>
                    </eq>
                </tr>
            </thead>
            <volist name="list" id="report">
                <tr>
                    <td>
                        <input type="checkbox" name="id[]" value="{{$report.id}}" />
                        <input type="hidden" name="user_id" value="{{$report.user_id}}" />
                    </td>
                    <td>{{$report.report_id}}</td>
                    <td>{{$report.email}} ({{$report.user_id}})</td>
                    <td><eq name="report.report_type" value="1">话题<else/>评论</eq></td>
                <td>
                    <eq name="report.report_type" value="1">
                    <a href="{{$Think.config.SITE_URL}}/tweets/r/tid/{{$report.object_id}}" target="_blank">tweets_id: {{$report.object_id}}</a>
                <else/>
                <a href="{{$Think.config.SITE_URL}}/tweets/r/cid/{{$report.object_id}}" target="_blank">comment-id: {{$report.object_id}}</a>
                </eq>
                </td>
                <td>{{$report.content}}</td>
                <td>{{$report.create_time|friendly_date=###,full}}</td>
                <td>
                    <eq name="report.status" value="0">
                        未处理
                    <else/>
                        <eq name="report.status" value="1">
                            <abbr class="green" title="处理时间：{{$report.dispose_time|friendly_date=###,full}}">已同意</abbr>
                        <else/>
                            <abbr class="red" title="处理时间：{{$report.dispose_time|friendly_date=###,full}}">已拒绝</abbr>
                        </eq>
                    </eq>
                </td>
                <eq name="report.status" value="0">
                <td>
                    <a href="#;" data-object-id="{{$report.object_id}}" data-report-id="{{$report.report_id}}" class="btn_delete">回应</a>&nbsp;
                    <a href="__URL__/dispose/act/refuse/id/{{$report.report_id}}" class="btn_refuse">直接拒绝</a>&nbsp;
                </td>
                </eq>
                </tr>
            </volist>
        </table>
        <empty name="list">
        <p class="nodata">没有需要处理的举报</p>
        </empty>
    </form>
    <include file="Public:paging" />
</div>
<script>
    Do(function(){
        $("input.check_all:checkbox").click(function(e){
            $("input[name=" + $(this).attr("name") + "]:checkbox").not(this).attr("checked",function(){
                return !this.checked;
            });
        }); 
        $(".btn_delete").click(function(){
            var self = this;
            new Cute.ui.dialog().layer("回应",{
                content: Cute.template("REPORT",{
                    id: $(self).attr("data-report-id"),
                    object_id: $(self).attr("data-object-id")
                }),
                mask: true,
                buttons: [{
                        title: '同意',
                        type: 'main',
                        close: false,
                        func: function() {
                            var obj = this.pannel.find("textarea[name=content]");
                            Cute.api.post("__URL__/dispose/act/delete", this.pannel.find("form").serialize(), function(json) {
                                if (json.status > 0) {
                                    this.close();
                                    new Cute.ui.dialog().suggest("同意成功！");
                                }else{
                                    alert(json.info);
                                }
                            }.bind(this));
                        }
                    }, {
                        title: '拒绝',
                        type: 'main',
                        close: false,
                        func: function() {
                            var obj = this.pannel.find("textarea[name=content]");
                            Cute.api.post("__URL__/dispose/act/refuse", this.pannel.find("form").serialize(), function(json) {
                                if (json.status > 0) {
                                    this.close();
                                    new Cute.ui.dialog().suggest("拒绝成功！");
                                }else{
                                    alert(json.info);
                                }
                            }.bind(this));
                        }
                    }]
            });
        });
    });
</script>
<script type="text/plain" id="_REPORT_TPL_">
    <div class="d_content">
        <form action="__URL__/save" method="post">
            <textarea class="textarea" autofocus="true" placeholder="请输入原因.." name="content" style="width:100%;"></textarea>
            <input type="hidden" name="id" value="<#=id#>" />
            <input type="hidden" name="object_id" value="<#=object_id#>" />
        </form>
        </div>
</script>
<include file="Public:footer" />
